package com.example.springbatcvh.controller;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author jie
 * @date 2019/3/25 0025 -17:23
 */
@RestController
public class HelloController {

    @Resource
    JobLauncher jobLauncher;
    @Resource
    Job job;

    @GetMapping("/hello")
    public void hello(){
        try {
            jobLauncher.run(job, new JobParameters());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
